import torch
from torch import nn

inputs = torch.tensor([1, 2, 3], dtype=torch.float32)
target = torch.tensor([0, 2, 5], dtype=torch.float32)

print(float(nn.L1Loss()(inputs, target))) # (1 + 0 + 2) / 3
print(float(nn.MSELoss()(inputs, target))) # (1 ** 2 + 0 + 2 ** 2) / 3

i2 = torch.tensor(1, dtype=torch.float32)
t2 = torch.tensor(0, dtype=torch.float32)
print(float(nn.L1Loss()(i2, t2)))

inputs2 = torch.tensor([[0.1, 0.2, 0.3]])
target2 = torch.tensor([1])

print(float(nn.CrossEntropyLoss()(inputs2, target2)))